/**
 *
 */
package com.ybkj.daijia.server.service.impl;

import com.ybkj.daijia.server.mapper.DriverChoseLevelMapper;
import com.ybkj.daijia.server.model.DriverChoseLevel;
import com.ybkj.daijia.server.service.DriverChoseLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Shine
 *
 */
@Service
public class DefaultDriverChoseLevelService implements DriverChoseLevelService {

    @Autowired
    private DriverChoseLevelMapper driverChoseLevelMapper;

    @Transactional(rollbackFor = Exception.class)
    public DriverChoseLevel insertRecord(DriverChoseLevel driverChoseLevel) {

        driverChoseLevelMapper.insertRecord(driverChoseLevel);

        return driverChoseLevel;

    }

    @Transactional(rollbackFor = Exception.class)
    public DriverChoseLevel updateByPrimaryKey(DriverChoseLevel driverChoseLevel) {

        driverChoseLevelMapper.updateByPrimaryKey(driverChoseLevel);

        return driverChoseLevel;
    }

    @Override
    public DriverChoseLevel findByDriverAndLevelAndCompany(Long driverId, Long driverLevelId,
        Long companyId) {

        return driverChoseLevelMapper.selectByPrimaryKey(driverId, driverLevelId, companyId);
    }

    @Override
    public DriverChoseLevel findByDriverAndCompany(Long driverId, Long companyId) {

        return driverChoseLevelMapper.selectByDriverAndCompany(driverId, companyId);
    }

    @Transactional(rollbackFor = Exception.class)
    public void delete(Long driverId, Long driverLevelId) {
        driverChoseLevelMapper.deleteByDriverAndDriverLevel(driverId, driverLevelId);
    }


    @Transactional(rollbackFor = Exception.class)
    public void deleteByDriver(Long driverId) {

        driverChoseLevelMapper.deleteByDriver(driverId);

    }


    @Transactional(rollbackFor = Exception.class)
    public void deleteByDriverLevel(Long driverLevelId) {

        driverChoseLevelMapper.deleteByDriverLevel(driverLevelId);

    }


}